<template>
  <div class="login">
    <div style="width: 100%; margin-bottom: 15px;">
      <img class="banner" width="100%" src="@/assets/images/banner.png" />
    </div>
    <el-form ref="checkForm" :model="checkForm" :rules="checkRules" class="login-form">
        <el-form-item prop="idNum">
          <el-input v-model="checkForm.idNum" type="text" auto-complete="off" placeholder="证件号码">
          </el-input>
        </el-form-item>
        
        <el-form-item style="width:100%;">
          <el-button
            :loading="loading"
            size="medium"
            type="primary"
            style="width:100%;"
            @click.native.prevent="handleCheck"
          >
            <span v-if="!loading">验 证</span>
            <span v-else>验 证 中...</span>
          </el-button>
        </el-form-item>
      </el-form>

  </div>
</template>


<script>


import { getFromInfo,getFromInfoList,getFromFidByIDNum } from '@/api/index.js'

export default {
  name: "selectprj",
  data() {
    return {
      checkForm: {
        idNum: ""
      },
      loading:false,
      checkRules: {
        idNum: [
          { required: true, trigger: "blur", message: "证件号码不能为空" }
        ]
      },

    };
  },

  created() {
   
    this.queryFormList();
    

  },
  methods: {
    queryFormList () {
      let that = this;
      getFromInfoList().then(res=>{
        if(res.code==0)
        {
          that.formList = res.data;
        }
      });
    },
    handleCheck() {
      let that = this;
      
      this.$refs.checkForm.validate(valid => {
        if (valid) {
          that.loading = true;
          let formInfo = JSON.parse(localStorage.getItem("formInfo"));
          let param = {'fromTableName':formInfo.fromTableName,'idNum':that.checkForm.idNum};
          getFromFidByIDNum(param).then(res=>{
            if(res.code==0)
            {
              console.log(res.data)
              if(res.data==null)
              {
                that.$message.error('证件号码不存在，请检查');
                // that.$message({
                //   message: '居中的文字',
                //   center: true,
                //   duration: 0,
                // });

                that.loading = false;
              }
              else
              {
                that.$router.push({ path: "/viewfrom?tablefid="+res.data});
              }
            }else
            {
              that.$message.error('系统开小差了，请重试')
            }
          });
        }
      });
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss">
.login {
  // display: flex;
  // justify-content: center;
  // align-items: center;
  height: 100%;
  /*background-image: url("../assets/image/login-background.jpg");*/
  background-size: cover;
}
.title {
  margin: 0px auto 30px auto;
  text-align: center;
  color: #707070;
}

.login-form {
  border-radius: 6px;
  background: #ffffff;
  width: calc(100% - 40px);
  margin: 0 auto;
  // padding: 25px 25px 5px 25px;
  .el-input {
    height: 38px;
    input {
      height: 38px;
    }
  }
  .input-icon {
    height: 39px;
    width: 14px;
    margin-left: 2px;
  }
}
.login-tip {
  font-size: 13px;
  text-align: center;
  color: #bfbfbf;
}
.login-code {
  width: 33%;
  height: 38px;
  float: right;
  img {
    cursor: pointer;
    vertical-align: middle;
  }
}
.el-login-footer {
  height: 40px;
  line-height: 40px;
  position: fixed;
  bottom: 0;
  width: 100%;
  text-align: center;
  color: #fff;
  font-family: Arial;
  font-size: 12px;
  letter-spacing: 1px;
}
</style>
